package com.example.springbootaop.listener;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * @Description: 切面
 * @Author: zhangdongkang
 * @Date: 2022/4/24
 **/
@Component
@Aspect
public class OrderEventAspect {

	/**
	 * @Description: 订单切面，转化为监听事件，异步解耦
	 * @Author: zhangdongkang
	 * @Date: 2022/4/24
	 **/
	@Around("@annotation(orderEvent)")
	public Object around(ProceedingJoinPoint point, OrderEvent orderEvent) throws Throwable {
		String className = point.getTarget().getClass().getName();
		String methodName = point.getSignature().getName();
		Object obj = point.proceed();

		System.out.println("[类名]:" + className);
		System.out.println("[方法]:" + methodName);
		System.out.println("[返回值]:" + obj);
		return obj;
	}

}
